﻿@using Maanfee.Web.Printing
@using Microsoft.AspNetCore.Http
@using System.Reflection
@page "/"
@inherits _BaseView

<MaanfeeDashboardPage>
    <MaanfeeDashboardPageHeader PageTitle="@DashboardResource.StringDashboard" />

    <MudGrid>
        <MudItem md="12" xs="12">
            <MudAlert Severity="Severity.Success" ContentAlignment="HorizontalAlignment.Start">
                @ApplicationResource.StringWelcomeMessage
            </MudAlert>
        </MudItem>
        <MudItem md="4">
            <MaanfeeDashboardTile Title="Online Users" Value="-50" Color="Color.Primary" ChartClass="mud-primary" Icon="@Icons.Material.Filled.TrendingDown" Description="Description" />
        </MudItem>
        <MudItem md="4">
            <MaanfeeDashboardTile Title="Active Users" Value="200" Color="Color.Secondary" ChartClass="mud-secondary" Icon="@Icons.Material.Filled.TrendingUp" Description="Description" />
        </MudItem>
        <MudItem md="4">
            <MaanfeeDashboardTile Title="Deleted Users" Value="250" Color="Color.Tertiary" ChartClass="mud-tertiary" Icon="@Icons.Material.Filled.TrendingFlat" Description="Description" />
        </MudItem>
        <MudItem md="6">

        </MudItem>

        <MudItem md="12" xs="12">
            @*	<MudButton OnClick="@((e) => OpenDialog(fullScreen))" Variant="Variant.Filled" Color="Color.Secondary">
            کتابی
            </MudButton>

            @code {

            private DialogOptions fullScreen = new DialogOptions()
            {
            FullScreen = true,
            CloseButton = true,
            NoHeader = true,
            CloseOnEscapeKey = true,
            };

            private void OpenDialog(DialogOptions options)
            {
            Dialog.Show<BookletComponent>(string.Empty, options);
            }

            }
            *@
        </MudItem>
        <MudItem md="12" xs="12">
            @*	@Http.BaseAddress.AbsoluteUri*@
        </MudItem>
        <MudItem md="12" xs="12">
            @*@Http.BaseAddress.DnsSafeHost | @Http.BaseAddress.Host | @Http.BaseAddress.Port | @Http.BaseAddress.Scheme*@
        </MudItem>
        <MudItem md="12" xs="12">
            @*<img src="/StaticFiles/Profile/AAA/BBB/red-rose.jpg" />*@
        </MudItem>
    </MudGrid>

</MaanfeeDashboardPage>

@code {

    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();

        try
        {
            var Callback = await Http.GetFromJsonAsync<CallbackResult<SysRelease>>($"api/SysReleases/GetLatestRelease");
            if (Callback.Data != null)
            {
                if (string.Compare(Callback.Data.Version, SharedLayoutSettings.CurrentVersion) > 0)
                {
                    DialogParameters DialogParameters = new DialogParameters();
                    DialogParameters.Add("SysRelease", Callback.Data);

                    var dialog = Dialog.Show<Settings.SysReleases.DialogReleaseControl>(string.Empty, DialogParameters,
                                new DialogOptions()
                                    {
                                        NoHeader = true,
                                        MaxWidth = MaxWidth.Medium,
                                        FullWidth = true,
                                        Position = DialogPosition.Center,
                                        BackdropClick = false,
                                    });
                }
            }
            else
            {
                Snackbar.Add(Callback.Error.ToString(), Severity.Error);
            }
        }
        catch (Exception ex)
        {
            Snackbar.Add($"{DashboardResource.StringError} : " + ex.Message, Severity.Error);
        }
    }

}
